package com.qf.service.impl;

import com.qf.dao.Card2Dao;
import com.qf.dao.impl.Card2DaoImpl;
import com.qf.entity.Card2;
import com.qf.service.Card2Service;

import java.util.List;

public class Card2ServiceImpl implements Card2Service {
    private Card2Dao card2Dao = new Card2DaoImpl();
    @Override
    public boolean add(Card2 card2) {
        if (card2Dao.add(card2) >= 1 ){
            return true;
        }
        return false;
    }

    @Override
    public List<Card2> findAllCard2(Integer uid) {
        List<Card2> allCard2 = card2Dao.findAllCard2(uid);
        return allCard2;
    }



    @Override
    public boolean bingding(String id1,String id2) {
        if (card2Dao.bingding(id1,id2) >= 1){
            return true;
        }
        return false;
    }

    @Override
    public List<Card2> findByUid(String uid) {
        return card2Dao.selectByUid(uid);
    }

    @Override
    public Boolean editBalanceByID(double num, String id) {
        int res = card2Dao.updateBalanceByID(num, id);
        if (res >= 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean yanzheng(String id2, String name, String id1, String phone, String password) {
        Card2 card2 = card2Dao.yanzheng(id2,name,id1,phone,password);
        if (card2 != null){
            return true;
        }
        return false;
    }

    @Override
    public Card2 yanzheng(String id2, String name) {
        Card2 card2 = card2Dao.yanzheng(id2,name);
        if (card2 != null){
            return card2;
        }
        return null;
    }

    @Override
    public boolean tixian(String id2, double money) {
        int a = card2Dao.zhifu(id2,money);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public boolean jianqian(String id2, double money) {
        int a = card2Dao.zhifu(id2,money);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public Card2 findCard2ById(String id1) {
        Card2 card2 = card2Dao.findById(id1);
        return card2;
    }

    @Override
    public boolean huodechongzhi(String id2, double money) {
        int a = card2Dao.shoukuan(id2,money);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public boolean jiaqian(String id2, double money) {
        int a = card2Dao.shoukuan(id2,money);
        if (a >= 1){
            return true;
        }
        return false;
    }
}
